package de.fhffm.scs.simulator.gui;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.List;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;

public class SimulationAppender extends AppenderBase<ILoggingEvent> {

    private List logList;

    public SimulationAppender(List logList) {
        setName("SimulationAppender");
        this.logList = logList;
    }

    @Override
    protected void append(final ILoggingEvent logEvent) {
        Display.getDefault().asyncExec(new Runnable() {

            @Override
            public void run() {
                logList.add(logEvent.getFormattedMessage());
            }
        });

    }

}
